#!/bin/sh -x

# Oracle/prefix paths
PREFIX="${PKG_PREFIX}"
ORACLEPREFIX="/usr/lib/oracle"
ORADIR="${ORACLEPREFIX}/xe"

case $2 in
POST-DEINSTALL)

#
# post-uninstall script extracted from the OracleXE RPM package
# and adapted for FreeBSD environment
#

#XXX
/compat/linux/sbin/ldconfig >/dev/null

rm -fr $ORADIR/app/oracle/product/10.2.0/client
rm -fr $ORADIR/app/oracle/doc
rm -fr $PREFIX/share/doc/oracle_xe_client
rm -fr $PREFIX/share/desktop-menu-files/oraclexe-client-10g.directory
rm -fr $PREFIX/share/desktop-menu-files/oraclexe-client-gethelp.directory
rm -fr /var/lib/menu/kde/Applications/oraclexe-client
rm -fr $PREFIX/share/gnome/vfolders/oraclexe-client-10g.directory
rm -fr $PREFIX/share/gnome/vfolders/oraclexe-client-gethelp.directory
if [ -f /etc/xdg/menus/applications.menu ]
then
	rm -f $PREFIX/share/desktop-directories/oraclexe-client-10g.directory
	rm -f $PREFIX/share/desktop-directories/oraclexe-client-gethelp.directory
	rm -f /etc/xdg/menus/oraclexe-client.menu
	sed -i '/<\!\-- Oracle XE Client \-->/,/<\!\-- End of Oracle XE Client \-->/d' /etc/xdg/menus/applications.menu 

elif [ -f /etc/X11/desktop-menus/applications.menu ]
then
	sed -i '/<\!\-- Oracle XE Client \-->/,/<\!\-- End of Oracle XE Client \-->/d' /etc/X11/desktop-menus/applications.menu 
elif [ -f /etc/xdg/menus/applications-merged/kde-essential.menu ]
then
	rm -f $PREFIX/share/desktop-directories/oraclexe-client-10g.directory
	rm -f $PREFIX/share/desktop-directories/oraclexe-client-gethelp.directory
	rm -f /etc/xdg/menus/oraclexe-client.menu
	sed -i '/<\!\-- Oracle XE Client \-->/,/<\!\-- End of Oracle XE Client \-->/d' /etc/xdg/menus/applications-merged/kde-essential.menu
fi

exit 0
;;

esac

